Skip to content

build: Reuse //base:build_date_internal for //copied_base/base:build_date#10021

Open
hferreiro wants to merge 1 commit intoyoutube:mainfrom
hferreiro:android-timestamp
Open

build: Reuse //base:build_date_internal for //copied_base/base:build_date#10021
hferreiro wants to merge 1 commit intoyoutube:mainfrom
hferreiro:android-timestamp

Conversation

@hferreiro
Copy link
Copy Markdown
Collaborator

https://crrev.com/c/6551784 and https://crrev.com/c/6546841 modified
//base:build_date to simply copy the generated timestamp header file
from the default toolchain and avoid having to redo the work in every
toolchain. The changes also introduced an assertion to ensure that was
the case.

In AOSP builds, that assertion fails because it uses copied_base with
the old code. This PR fixes this by reusing the same mechanism that is
already in place at //base:build_date_internal.

Bug: 495203133

…date

https://crrev.com/c/6551784 and https://crrev.com/c/6546841 modified
//base:build_date to simply copy the generated timestamp header file
from the default toolchain and avoid having to redo the work in every
toolchain.  The changes also introduced an assertion to ensure that was
the case.

In AOSP builds, that assertion fails because it uses copied_base with
the old code. This PR fixes this by reusing the same mechanism that is
already in place at //base:build_date_internal.

Bug: 495203133
@hferreiro hferreiro requested a review from a team as a code owner April 14, 2026 13:14
@hferreiro hferreiro requested a review from yell0wd0g April 14, 2026 13:14
@github-actions
Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


build: Reuse build_date_internal for copied_base

Chromium changes updated //base:build_date to copy the generated
timestamp header from the default toolchain, avoiding redundant work
and introducing an assertion.

The old mechanism in //copied_base caused this assertion to fail
during AOSP builds. This change updates //copied_base to reuse the
same build_date header generated by //base:build_date_internal,
aligning it with the new Chromium behavior and fixing the AOSP build.

Bug: 495203133

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies copied_base/base/BUILD.gn to replace the build_date action with a copy target that reuses a header generated by //base:build_date_internal. It also adds the generated header to the base component's sources. A review comment suggests using get_label_info to dynamically resolve the source path instead of using a hardcoded string, which improves maintainability and adheres to GN best practices.

]
copy("build_date") {
# Reuse the file generated by //base:build_date_internal.
sources = [ "$root_build_dir/gen/base/generated_build_date_internal.h" ]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a hardcoded path for the source file is brittle as it assumes a specific directory structure within the build output. It is more robust to use get_label_info to dynamically determine the output directory of the dependency, especially when referencing a target in a different toolchain. This aligns with Chromium GN best practices for maintainability.

Suggested change
sources = [ "$root_build_dir/gen/base/generated_build_date_internal.h" ]
sources = [ get_label_info("//base:build_date_internal($default_toolchain)", "target_gen_dir") + "/generated_build_date_internal.h" ]
References
  1. Adhere to established upstream Chromium style guides for GN files, which prefer using get_label_info for cross-target path references to avoid brittle hardcoded paths. (link)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses the same sources that //base:build_date uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant